import request from "@/request";

// 参数接口
export interface UpdateSortsParams {
    id?: number;
    icon?: string;
    name?: string;
    code?: string;
    createBy?: string;
    createTime?: string;
    updateBy?: string;
    updateTime?: string;
    undock?: number;
    unlucky?: number;
    remark?: string;
}

// 响应接口
export interface UpdateSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 修改编号
 * @param {object} params $!{table.comment}
 * @param {number} params.id 编号
 * @param {string} params.icon 类别图标
 * @param {string} params.name 类别名称
 * @param {string} params.code 类别代码
 * @param {string} params.createBy 创建者
 * @param {string} params.createTime 创建时间
 * @param {string} params.updateBy 更新者
 * @param {string} params.updateTime 更新时间
 * @param {number} params.undock 伪删除（0-已 1-未）
 * @param {number} params.unlucky 状态（0-禁用 1-正常）
 * @param {string} params.remark 备注
 * @returns
 */
export function updateSorts(params: UpdateSortsParams): Promise<UpdateSortsRes> {
    return request.post(`/sortsEntity/update`, params);
}

// 响应接口
export interface RecoverListSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 恢复列表
 * @returns
 */
export function recoverListSorts(): Promise<RecoverListSortsRes> {
    return request.post(`/sortsEntity/recoverList`);
}

// 响应接口
export interface RecoverSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 恢复数据
 * @param {string} param
 * @returns
 */
export function recoverSorts(param: string): Promise<RecoverSortsRes> {
    return request.post(`/sortsEntity/recover/${param}`);
}

// 响应接口
export interface ListPageSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 列表分页
 * @param {string} page
 * @param {string} pageSize
 * @returns
 */
export function listPageSorts(page: number, pageSize: number): Promise<ListPageSortsRes> {
    return request.post(`/sortsEntity/listPageSorts?page=${page}&pageSize=${pageSize}`);
}

// 参数接口
export interface InsertSortsParams {
    id?: number;
    icon?: string;
    name?: string;
    code?: string;
    createBy?: string;
    createTime?: string;
    updateBy?: string;
    updateTime?: string;
    undock?: number;
    unlucky?: number;
    remark?: string;
}

// 响应接口
export interface InsertSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 保存数据
 * @param {object} params $!{table.comment}
 * @param {number} params.id 编号
 * @param {string} params.icon 类别图标
 * @param {string} params.name 类别名称
 * @param {string} params.code 类别代码
 * @param {string} params.createBy 创建者
 * @param {string} params.createTime 创建时间
 * @param {string} params.updateBy 更新者
 * @param {string} params.updateTime 更新时间
 * @param {number} params.undock 伪删除（0-已 1-未）
 * @param {number} params.unlucky 状态（0-禁用 1-正常）
 * @param {string} params.remark 备注
 * @returns
 */
export function insertSorts(params: InsertSortsParams): Promise<InsertSortsRes> {
    return request.post(`/sortsEntity/insert`, params);
}

// 响应接口
export interface ImportExcelSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 导入数据
 * @param {string} file
 * @returns
 */
export function importExcelSorts(file: object): Promise<ImportExcelSortsRes> {
    return request.post(`/sortsEntity/importExcel`,file);
}

// 参数接口
export interface FindSortsParams {
    id?: number;
    icon?: string;
    name?: string;
    code?: string;
    createBy?: string;
    createTime?: string;
    updateBy?: string;
    updateTime?: string;
    undock?: number;
    unlucky?: number;
    remark?: string;
}

// 响应接口
export interface FindSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 条件查询
 * @param {object} params $!{table.comment}
 * @param {number} params.id 编号
 * @param {string} params.icon 类别图标
 * @param {string} params.name 类别名称
 * @param {string} params.code 类别代码
 * @param {string} params.createBy 创建者
 * @param {string} params.createTime 创建时间
 * @param {string} params.updateBy 更新者
 * @param {string} params.updateTime 更新时间
 * @param {number} params.undock 伪删除（0-已 1-未）
 * @param {number} params.unlucky 状态（0-禁用 1-正常）
 * @param {string} params.remark 备注
 * @returns
 */
export function findSorts(params: FindSortsParams): Promise<FindSortsRes> {
    return request.post(`/sortsEntity/findSorts`, params);
}

// 响应接口
export interface FindByNameSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 查询名称
 * @param {string} param
 * @returns
 */
export function findByNameSorts(param: string): Promise<FindByNameSortsRes> {
    return request.post(`/sortsEntity/findByNameSorts/${param}`);
}

// 响应接口
export interface FindByIDSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 查询编号
 * @param {string} param
 * @returns
 */
export function findByIDSorts(param: string): Promise<FindByIDSortsRes> {
    return request.post(`/sortsEntity/findByIDSorts/${param}`);
}

// 响应接口
export interface ExportExcelSortsRes {
}

/**
 * 导出数据
 * @returns
 */
export function exportExcelSorts(): Promise<ExportExcelSortsRes> {
    return request.post(`/sortsEntity/exportExcel`, {}, {
        responseType: "blob"
    });
}

// 响应接口
export interface DeleteTempSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 暂时删除
 * @param {string} param
 * @returns
 */
export function deleteTempSorts(param: string): Promise<DeleteTempSortsRes> {
    return request.post(`/sortsEntity/deleteTemp/${param}`);
}

// 响应接口
export interface DeleteSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 永久删除
 * @param {string} param
 * @returns
 */
export function deleteSorts(param: string): Promise<DeleteSortsRes> {
    return request.post(`/sortsEntity/delete/${param}`);
}

// 响应接口
export interface ListSortsRes {
    message: string;
    success: boolean;
    code: number;
    data: Record<string, unknown>;
}

/**
 * 列表
 * @returns
 */
export function listSorts(): Promise<ListSortsRes> {
    return request.post(`/sortsEntity/listSorts`);
}
